package com.jboa.service.impl;

import java.util.List;

import com.jboa.dao.FunctionDao;
import com.jboa.dao.ModuleDao;
import com.jboa.model.Function;
import com.jboa.model.Module;
import com.jboa.service.FunctionService;



public class FunctionServiceImpl implements FunctionService {

	private FunctionDao functionDao;
	private ModuleDao moduleDao;
	public void setFunctionDao(FunctionDao functionDao) {
		this.functionDao = functionDao;
	}

	public void setModuleDao(ModuleDao moduleDao) {
		this.moduleDao = moduleDao;
	}

	public List<Function> findFByMId(Module m) {
		// TODO Auto-generated method stub
		return this.functionDao.findByProperty("module.id", m.getId());
	}

	public List<Function> findFunction(List<Integer> rid, Module m) {
		// TODO Auto-generated method stub
		return null;
	}

	public Function findSingleFunction(Function f) {
		
		return this.functionDao.findById(f.getId());
	}

	public void modifyFunction(Function f) {
		this.functionDao.update(f);

	}

	public void newFunction(Function f, Integer mid) {
		Module module =this.moduleDao.findById(mid);
		f.setModule(module);
		this.functionDao.save(f);

	}

	public void removeFunction(Function f) {
		this.functionDao.delete(f);

	}

}
